﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="UploadPreview.ascx.cs" Inherits="UserControl_UploadPreview" %>
<%@ Register Src="~/UserControl/UboxTemplate.ascx" TagPrefix="uc1" TagName="UboxTemplate" %>


<style>
    .black-container{
    display: none;
    cursor: -webkit-zoom-out;
    z-index: 2000;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    padding-top: 40px;
    background-color: rgba(0, 0, 0, 0.45);
    overflow-y: auto; /*垂直滾輪*/
}
</style>

<div class="black-container">
    <uc1:UboxTemplate runat="server" ID="UboxTemplate" />
</div>

<script>
    // btn登入鍵click event. show預覽畫面
    $('#btnPreview').click(function () {
        //=============
        var ct = CKEDITOR.instances.TextBox1.getData();
        $("#articleContent").html(ct);
        $("#articleTitle").text($("#TitleTxt").val());
        //==
        if (ActionSwitch == "NewPost") {
            var thefile = document.getElementById("eleUploadTitlePage").files;
            if (thefile[0]==null)
            {
                alert("尚未選擇首頁圖");
                return;
            }
            else
            {
                var reader = new FileReader;
                reader.readAsDataURL(thefile[0]);
                reader.onload = function (e) {
                    var filecontent = e.target.result;
                    $("#imgUboxCover").attr("src", filecontent);
                }
            }
        }
        else if (ActionSwitch == "EditLoad")
        {
            var thefile = document.getElementById("eleUploadTitlePage").files;
            if (thefile[0] == null) {
                $("#imgUboxCover").attr("src", "data:image/jpg;base64," + tempimg);//.attr("heigh", "95").attr("class", "IntroductionArticleImage");
            }
            else {
                var reader = new FileReader;
                reader.readAsDataURL(thefile[0]);
                reader.onload = function (e) {
                    var filecontent = e.target.result;
                    $("#imgUboxCover").attr("src", filecontent);
                }
            }
            //alert(ActionSwitch);
        }
        $("#imgUboxCover").attr("style", "display:inline").attr("height", "400px").attr("style","max-width:100%");
        $("#DivimgUboxCover").attr("style", "text-align: center;");
        //==
        //=============
        $('body').css('overflow', 'hidden');
        $('.black-container').fadeTo(500, 1).show();
        // 先將body拉霸隱藏 才顯示預覽畫面(包含預覽畫面的拉霸)
    });

    // btn取消&表單外部黑色屏蔽click event
    $('.black-container').click(function () {
        $('.black-container').fadeTo(500, 0, hideBlackContainer);
    });

    function hideBlackContainer() {
        $('.black-container').hide();
        $('body').css('overflow', 'scroll');
        // 當預覽黑幕全部消失 才顯示body的拉霸
    };
</script>